-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite Min/Max to handle all cases correctly. Fixes 545 spectest failures. #863
Conversation
Fixes 545 spectest failures.
.build_call(intrinsics.minimum_f32, &[v1, v2], &state.var_name()) | ||
.try_as_basic_value() | ||
.left() | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add comments in each of this implementations adding context, such as:
LLVM minmax doesn't work on the versions I tried (8, 9) because ...
So we are writing our own implementation of minmax each time we call `f32min` ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Apart from the comment added. Rather than adding the IR for minmax each time that we call min on a value, can we just create 4 different functions (in the LLVM IR) and call them? |
I don't think we should do that? The first reason is that when we call Secondly, we're in the middle of emitting a function. LLVM is fine with seeing more functions at any time, but |
bors r+ |
863: Rewrite Min/Max to handle all cases correctly. Fixes 545 spectest failures. r=nlewycky a=nlewycky # Description The llvm backend was not quite following the Wasm spec for {F32,F64,F32x4xF64x2}{Min,Max}. We used the `@llvm.minnum` and `@llvm.maxnum` intrinsics which don't handle the corner cases the same. When we tried to use `@llvm.minimum` and `@llvm.maximum` which do, we get an internal error from the x86 backend. I was hoping that crash would go away with the upgrade to LLVM 9, but it does not. Reimplement these operations using plain LLVM instructions. # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Nick Lewycky <[email protected]>
Build succeeded
|
Description
The llvm backend was not quite following the Wasm spec for {F32,F64,F32x4xF64x2}{Min,Max}. We used the
@llvm.minnum
and@llvm.maxnum
intrinsics which don't handle the corner cases the same. When we tried to use@llvm.minimum
and@llvm.maximum
which do, we get an internal error from the x86 backend. I was hoping that crash would go away with the upgrade to LLVM 9, but it does not.Reimplement these operations using plain LLVM instructions.
Review